package com.lmaos.basetools.timer;

import java.io.StringReader;
import java.util.Properties;

import org.w3c.dom.Element;

import com.lmaos.basetools.base.SParamMap;

public class BaseTimerConfig extends SParamMap{
	private static final long serialVersionUID = 1L;
	private String tagName;
	private String content;
	private Element tagNode;
	
	public BaseTimerConfig(String tagName, String content) {
		this.tagName = tagName;
		this.content = content;
	}
	
	public BaseTimerConfig(String tagName, String content, Element tagNode) {
		super();
		this.tagName = tagName;
		this.content = content;
		this.tagNode = tagNode;
	}

	public BaseTimerConfig(String tagName) {
		super();
		this.tagName = tagName;
	}

	public BaseTimerConfig setTagName(String tagName) {
		this.tagName = tagName;
		return this;
	}
	public String getTagName() {
		return tagName;
	}
	public BaseTimerConfig setContent(String content) {
		this.content = content;
		return this;
	}
	public String getContent() {
		return content;
	}
	public Element getTagNode() {
		return tagNode;
	}
	private volatile Properties properties = null;
	public Properties getProperties(){
		if(properties == null&&content!=null){
			try {
				properties = new Properties();
				properties.load(new StringReader(content));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return properties;
	}
	
	/**
	 * 说明：获得当前节点下的节点集合		<br>
	 * 时间：2017年6月26日 上午9:59:52
	 *
	 * @return
	 */
	public BaseTimerConfigGroup getBaseTimerConfigGroup(){
		BaseTimerConfigGroup baseTimerConfigGroup = TimerStart.getBaseTimerConfigGroupByXmlNode(tagNode);
		return baseTimerConfigGroup;
	}
}
